package com.wanglibao.woodtrade.woodtrade.ui.fragment.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.wanglibao.woodtrade.woodtrade.R;

/**
 * Created by lugg on 2016/5/11.
 */
public class ShopFragmentWoodTypeAdapter extends BaseAdapter {

    Context context;
    String[] datas;

    public ShopFragmentWoodTypeAdapter(Context context, String[] datas) {
        this.context = context;
        this.datas = datas;
    }

    @Override
    public int getCount() {
        return datas.length;
    }

    @Override
    public Object getItem(int position) {
        return datas[position];
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        TextView tv = null;
        if (convertView == null){
            convertView = View.inflate(context, R.layout.tv_item,null);
        }
        tv = (TextView) convertView;
        tv.setText(datas[position]);
        return convertView;
    }

    public void update(String[] datas){
        this.datas = datas;
        super.notifyDataSetChanged();
    }
}
